package kr.co.bettersoft.waitnumberstoret.adapter;

import java.util.List;

import kr.co.bettersoft.waitnumberstoret.activity.R;
import kr.co.bettersoft.waitnumberstoret.common.CommonConstant;
import kr.co.bettersoft.waitnumberstoret.domain.EventNotice;

import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
/**
 * 공지 리스트를 화면에 보여줄때 사용되는 아답터이다.
 * @author blue
 * 
 */
public class StoreNoticeListAdapter extends BaseAdapter {
	String TAG = "StoreNoticeListAdapter";
	private Context context;
	private final List<EventNotice> entries;
 
	// 폰트
	private Typeface typefaceNanumGothic= null; 
	private Typeface typefaceNanumGothicBold = null;
	
	public StoreNoticeListAdapter(Context context, List<EventNotice> entriesFn) {		
		this.context = context;
		this.entries = entriesFn;
		
		// 폰트 지정.
	    typefaceNanumGothic = Typeface.createFromAsset(context.getAssets(), CommonConstant.NanumGothic);  
	    typefaceNanumGothicBold = Typeface.createFromAsset(context.getAssets(), CommonConstant.NanumGothicBold);
	}
	Boolean blued = false;
	public View getView(int position, View convertView, ViewGroup parent) {
		
		//Log.d(TAG,"position::"+position);
		
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View listView;
		if (convertView == null) {
			listView = new View(context);
			listView = inflater.inflate(R.layout.adapter_main_notice_list, null);
		} else {
			listView = (View) convertView;
		}
 
		// set value into textview
		
		TextView textViewSubject = (TextView) listView.findViewById(R.id.store_notice_list_subject);
		TextView textViewRegisterDate = (TextView) listView.findViewById(R.id.store_notice_list_register_date);
		textViewSubject.setText(((EventNotice)entries.get(position)).getSubject());
		textViewRegisterDate.setText(((EventNotice)entries.get(position)).getRegisterDate());

		TextView storeNameView = (TextView) listView.findViewById(R.id.store_name_view);
		storeNameView.setText(((EventNotice)entries.get(position)).getCompanyName());		
		
		// 폰트 적용
		textViewSubject.setTypeface(typefaceNanumGothicBold);	
		storeNameView.setTypeface(typefaceNanumGothic);	
		textViewRegisterDate.setTypeface(typefaceNanumGothic);	
		
		return listView;
	}
 
	@Override
	public int getCount() {
		return entries.size();
	}
 
	@Override
	public Object getItem(int position) {
		return null;
	}
 
	@Override
	public long getItemId(int position) {
		return 0;
	}
 
}